<template>
  <div class="r">
    <div class="booklist">
      <div class="top">
        <div><p>审核</p></div>
        <div class="close" @click="closeDiv">x</div>
      </div>

      <div class="center">
        <p><span>活动名称：</span>{{ toSonData.shopName }}</p>
        <p><span>活动订单：</span>{{ toSonData.shopNum }}</p>
        <p><span>活动类型：</span>{{ toSonData.shopType }}</p>
        <p><span>活动学校：</span>{{ toSonData.collage }}</p>
        <p><span>价格：</span>{{ toSonData.price }}</p>
        <p><span>活动开始时间：</span>{{ toSonData.startTime }}</p>
        <p><span>活动结束时间：</span>{{ toSonData.endTime }}</p>
         <p><span>活动状态：</span>{{ toSonData.stuAuth }}</p>
      </div>
      <div class="btn">
        <button @click="golist(1)">开始</button>
        <button @click="golist(2)">结束</button>
        <button @click="deleList()">删除</button>
      </div>
      <True v-if="flag"   @close="guanbiceng" />
    </div>
  </div>
</template>

<script>
import { request } from "../../server_Api";

export default {
  name: "relstatus",
  props: ["toSonData"],
  data() {
    return {
      Sid: "",
      value: "",
      flag:false
    };
  },
 components:{
  
  },
  created() {
  
  },
  methods: {
    golist(value) {
      // this.$router.history.go(0)
      request({
        url: "/pc_changeHot",
        method: "POST",
        data: { Sid: this.toSonData.Sid, value},
      }).then((res) => {
       var dateStart = this.forDate(this.toSonData.startTime)
       var dateEnd = this.forDate(this.toSonData.startTime)
       var dateDay = this.forDate(new Date())
       
       if(value === 1){ 
          this.toSonData.stuAuth = "1"
          this.toSonData.title = "活动开始"
          this.$emit("close", false);
       }else if(value === 2){
          this.toSonData.stuAuth = "2"
          this.toSonData.title = "活动结束"
          this.$emit("close", false);
       }else{
         this.toSonData.title = "活动未开始"
         this.$emit("close", false);
       }

      });
      
    },
    deleList(){
      // pc_delet
       request({
        url: "/pc_delet",
        method: "POST",
        data: { Sid: this.toSonData.Sid},
      }).then((res) => {
        
      });

      this.$emit("close", false);
      this.$router.history.go(0)
    },
    closeDiv() {
      this.$emit("close", false);
    },
    // formatDate (value) {
    //   if (typeof (value) == 'undefined') {
    //       return ''
    //   } else {
    //       let date = new Date(parseInt(value))
    //       let y = date.getFullYear()
    //       let MM = date.getMonth() + 1
    //       MM = MM < 10 ? ('0' + MM) : MM
    //       let d = date.getDate()
    //       d = d < 10 ? ('0' + d) : d
    //       let h = date.getHours()
    //       h = h < 10 ? ('0' + h) : h
    //       let m = date.getMinutes()
    //       m = m < 10 ? ('0' + m) : m
    //       let s = date.getSeconds()
    //       s = s < 10 ? ('0' + s) : s
    //       return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
    //   }
    // }
    forDate(data){
      let date = new Date(data)
      return date.getTime()
    }
  },

  // watcher
};
</script>

<style scoped>
.r {
  background: rgba(0, 0, 0, 0.3);
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
}
.booklist {
  width: 30%;
  height: 60%;
  background: #fff;
  margin: 10% auto;
  border-radius: 10px;
  text-align: left;
}
.btn {
  padding: 30px 40px;
  text-align: right;
}
.btn button {
  background: none;
  border: none;
  outline: none;
  padding: 8px 16px;
  margin-left: 20px;
  font-weight: 600;
  border-radius: 4px;
}
.btn button:first-of-type {
  background: #2897ff;
  color: #fff;
  font-weight: 500;
  
}
.btn button:nth-child(2) {
  border: 1px solid #2897ff;
  background: none !important;
  color: #2897ff !important;
  font-weight: 500;
}
.btn button:nth-child(3) {
  background: none;
  border: 1px solid red;
  color: red;
  font-weight: 500;
}
.booklist .top {
  display: flex;
  margin: 20px;
  justify-content: space-between;
  align-items: center;
  padding: 40px 20px 10px 20px;
}
.booklist .top div:first-of-type {
  font-size: 24px;
  color: #2897ff;
  font-weight: 500;
}
.booklist .top div:last-of-type {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  text-align: center;
  line-height: 20px;
  color: rgba(0, 0, 0, 0.5);
  font-weight: 500;
  border-radius: 50%;
}
.center {
  padding: 0 20px 0 40px;
}
.center p:first-of-type {
  color: #2897ff;
}
.center p {
  margin-top: 18px;
}
.center span {
  color: rgba(0, 0, 0, 0.5);
}
</style>